function Create3dVideo()

infile = 'mydata.mat';   %file which contains data we wish to draw results for
outfile = 'mydata.avi';  %movie file name for output

nfps = 30; 				 %frames per second

%if angle = 1 camera is positioned at front perspecitive, angle = 2 side perspective, 
%angle = -1 general perspective (can be modified by changinging "view" parameters in for loop below)
angle = -1; 

load(infile);
aviobj = avifile(outfile, 'fps', nfps);

%physical distances in mm of recording area 
%fdist = front view horizontal distance 
%sdist = side view horizontal distance 
%vdist = vertical distance
fdist = 200;  
sdist = 200;
vdist = 200; 

%Generate video from nstart data frame to nend data frame
nstart = 1; 
nend = 500;  
%nend = length(ax1s);  %Enable this to use entire data set

fig = figure;

%colors for male
rm = 100;
gm = 210;
bm = 70;

%colors for female
rf = 240;
gf = 130;
bf = 171;

%neutral colors
rn = 240;
gn = 240;
bn = 240;

fcolors = zeros(len,3);
mcolors = zeros(len,3);

for i = 1:len
    fcolors = [rf/255,gf/255,bf/255];
    mcolors = [rm/255,gm/255,bm/255];
    bgcolors = [50/255, 50/255, 50/255];
end



lt = 2;

for k = nstart:nend
    
    nobjs = objs(k);
    
    hn = scatter3(1, 1, 1, 10, bgcolors, 'filled');
    
    %[k, i1s(k), i2s(k), vi1s(k), vi2s(k)] is contain data indexes and
    %vs contain the corresponding video frame for a data index
       
        
    for i = 1:nobjs
    
       
        ax1 = ax1s(k, :);
        ax2 = ax2s(k, :);
        
        ay1 = ay1s(k, :);
        ay2 = ay2s(k, :);
        
        az1 = az1s(k, :);
        az2 = az2s(k, :);
        
        ra = rm;
        ga = gm;
        ba = bm;
                        
        alx = [ax1(i) ax2(i)];
        aly = [ay1(i) ay2(i)];
        alz = [az1(i) az2(i)];
        

        hl = line(alx, [ay1(i) ay1(i)], [az1(i) az1(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line(alx, [ay2(i) ay2(i)], [az1(i) az1(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line(alx, [ay2(i) ay2(i)], [az2(i) az2(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line(alx, [ay1(i) ay1(i)], [az2(i) az2(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
    
        hl = line([ax1(i) ax1(i)], aly, [az1(i) az1(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line([ax1(i) ax1(i)], aly, [az2(i) az2(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line([ax2(i) ax2(i)], aly, [az2(i) az2(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line([ax2(i) ax2(i)], aly, [az1(i) az1(i)], 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
    
        hl = line([ax1(i) ax1(i)], [ay1(i) ay1(i)], alz, 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line([ax1(i) ax1(i)], [ay2(i) ay2(i)], alz, 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line([ax2(i) ax2(i)], [ay1(i) ay1(i)], alz, 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);
        hl = line([ax2(i) ax2(i)], [ay2(i) ay2(i)], alz, 'Color', [ra/255,ga/255,ba/255]);    
        set(hl,'LineWidth',lt);    
    end
    
    
    rotate(hn,[1 0 0],70);
        
    h = gca;  
    set( h, 'Color', [0.55,0.55,0.55] ); 
               
    
    if angle == 1 %front
	    view([0,-1.0,0.0])
    elseif angle == 2  %side
        view([1.0,0.0,0.1])     
    else 
        view([0.65,-1.0,0.5])
    end
    
    hold on
              
    scatter3(1, 1, 1, s, mcolors, 'filled')
    
    xlim([1 fdist])
    ylim([1 sdist]) 
    zlim([1 vdist])
 
    
    f = getframe(fig);
    aviobj = addframe(aviobj,f);    
    hold off
       
end

aviobj = close(aviobj);